package edu.towson.greenteam;

import java.awt.Color;
import java.util.LinkedList;
import java.util.Observable;
import java.util.Observer;

import edu.towson.greenteam.order.Orders;
import edu.towson.greenteam.table.Tables;
import javax.swing.JOptionPane;


public class SimulationUI extends javax.swing.JFrame implements Observer {

    Simulation sim = null;
    Thread t = null;

    /** Creates new form SimulationUI */
    public SimulationUI() {
        initComponents();

        //Only subscribe to Logger once
        Logger.GetInstance().addObserver(this);

        headerPanel.setOpaque(true);
        headerPanel.setBackground(new Color(255, 255, 255));
        controlPanel.setOpaque(true);
        controlPanel.setBackground(new Color(255, 255, 255));
        monitorPanel.setOpaque(true);
        monitorPanel.setBackground(new Color(255, 255, 255));
        txtareaDisplay.setEditable(false);

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        headerPanel = new javax.swing.JPanel();
        lblLogo = new javax.swing.JLabel();
        lblRole = new javax.swing.JLabel();
        controlPanel = new javax.swing.JPanel();
        btnSetNumTables = new javax.swing.JButton();
        btnSetCustomerFlowRate = new javax.swing.JButton();
        btnSetClockRate = new javax.swing.JButton();
        btnStartSimulation = new javax.swing.JButton();
        btnStopSimulation = new javax.swing.JButton();
        jSeparatorControl = new javax.swing.JSeparator();
        lblControlPanel = new javax.swing.JLabel();
        btnChangeStrategy = new javax.swing.JButton();
        monitorPanel = new javax.swing.JPanel();
        jSeparatorMonitor = new javax.swing.JSeparator();
        lblMonitorView = new javax.swing.JLabel();
        lblTablesHeader = new javax.swing.JLabel();
        lblNumWaiting = new javax.swing.JLabel();
        lblAverageWaitTime = new javax.swing.JLabel();
        lblOffersHeader = new javax.swing.JLabel();
        lblOffersSpend = new javax.swing.JLabel();
        lblOffersDiscount = new javax.swing.JLabel();
        lblOrdersHeader = new javax.swing.JLabel();
        lblMostOrdered = new javax.swing.JLabel();
        lblMostOrderedValue = new javax.swing.JLabel();
        lblLeastOrdered = new javax.swing.JLabel();
        lblLeastOrderedValue = new javax.swing.JLabel();
        lblTotalReceipts = new javax.swing.JLabel();
        lblTotalReceiptsValue = new javax.swing.JLabel();
        lblKitchenHeader = new javax.swing.JLabel();
        lblAveragePrepTime = new javax.swing.JLabel();
        lblAveragePrepTimeValue = new javax.swing.JLabel();
        lblDisplay = new javax.swing.JLabel();
        comboDisplayMenu = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtareaDisplay = new javax.swing.JTextArea();
        lblNumWaitingValue = new javax.swing.JLabel();
        lblAverageWaitTimeValue = new javax.swing.JLabel();
        txtOfferSpendValue = new javax.swing.JTextField();
        txtOfferDiscountValue = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(850, 700));
        setResizable(false);

        headerPanel.setToolTipText("");
        headerPanel.setPreferredSize(new java.awt.Dimension(800, 128));
        headerPanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        lblLogo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/edu/towson/greenteam/716dinerlogo.jpg"))); // NOI18N
        lblLogo.setToolTipText("");
        headerPanel.add(lblLogo, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 20, -1, -1));

        lblRole.setIcon(new javax.swing.ImageIcon(getClass().getResource("/edu/towson/greenteam/simulation.jpg"))); // NOI18N
        lblRole.setToolTipText("");
        headerPanel.add(lblRole, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 80, -1, -1));

        getContentPane().add(headerPanel, java.awt.BorderLayout.PAGE_START);

        controlPanel.setToolTipText("");
        controlPanel.setPreferredSize(new java.awt.Dimension(800, 120));
        controlPanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        btnSetNumTables.setText("Number of Tables");
        btnSetNumTables.setToolTipText("");
        btnSetNumTables.setPreferredSize(new java.awt.Dimension(182, 29));
        btnSetNumTables.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSetNumTablesActionPerformed(evt);
            }
        });
        controlPanel.add(btnSetNumTables, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 40, -1, -1));

        btnSetCustomerFlowRate.setText("Customer Flow Rate");
        btnSetCustomerFlowRate.setToolTipText("");
        btnSetCustomerFlowRate.setMaximumSize(new java.awt.Dimension(180, 29));
        btnSetCustomerFlowRate.setMinimumSize(new java.awt.Dimension(180, 29));
        btnSetCustomerFlowRate.setPreferredSize(new java.awt.Dimension(182, 29));
        btnSetCustomerFlowRate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSetCustomerFlowRateActionPerformed(evt);
            }
        });
        controlPanel.add(btnSetCustomerFlowRate, new org.netbeans.lib.awtextra.AbsoluteConstraints(240, 70, -1, -1));

        btnSetClockRate.setText("Clock Rate");
        btnSetClockRate.setToolTipText("");
        btnSetClockRate.setPreferredSize(new java.awt.Dimension(182, 29));
        btnSetClockRate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSetClockRateActionPerformed(evt);
            }
        });
        controlPanel.add(btnSetClockRate, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 40, -1, -1));

        btnStartSimulation.setText("Start");
        btnStartSimulation.setToolTipText("");
        btnStartSimulation.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnStartSimulationActionPerformed(evt);
            }
        });
        controlPanel.add(btnStartSimulation, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 40, -1, -1));

        btnStopSimulation.setText("Stop");
        btnStopSimulation.setToolTipText("");
        btnStopSimulation.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnStopSimulationActionPerformed(evt);
            }
        });
        controlPanel.add(btnStopSimulation, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 40, -1, -1));

        jSeparatorControl.setForeground(new java.awt.Color(255, 102, 204));
        jSeparatorControl.setToolTipText("");
        controlPanel.add(jSeparatorControl, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 20, 804, -1));

        lblControlPanel.setFont(new java.awt.Font("Lucida Grande", 1, 13));
        lblControlPanel.setText("Control Panel");
        lblControlPanel.setToolTipText("");
        controlPanel.add(lblControlPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(5, 16, -1, -1));

        btnChangeStrategy.setText("Orders Queue Strategy");
        btnChangeStrategy.setToolTipText("");
        btnChangeStrategy.setMaximumSize(new java.awt.Dimension(111, 29));
        btnChangeStrategy.setMinimumSize(new java.awt.Dimension(111, 29));
        btnChangeStrategy.setPreferredSize(new java.awt.Dimension(111, 29));
        btnChangeStrategy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnChangeStrategyActionPerformed(evt);
            }
        });
        controlPanel.add(btnChangeStrategy, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 70, 182, -1));

        getContentPane().add(controlPanel, java.awt.BorderLayout.PAGE_END);

        monitorPanel.setToolTipText("");
        monitorPanel.setPreferredSize(new java.awt.Dimension(800, 300));
        monitorPanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jSeparatorMonitor.setForeground(new java.awt.Color(255, 102, 204));
        jSeparatorMonitor.setToolTipText("");
        monitorPanel.add(jSeparatorMonitor, new org.netbeans.lib.awtextra.AbsoluteConstraints(102, 15, 800, -1));

        lblMonitorView.setFont(new java.awt.Font("Lucida Grande", 1, 13));
        lblMonitorView.setText("Monitor View");
        lblMonitorView.setToolTipText("");
        monitorPanel.add(lblMonitorView, new org.netbeans.lib.awtextra.AbsoluteConstraints(5, 10, -1, -1));

        lblTablesHeader.setFont(new java.awt.Font("Lucida Grande", 1, 14));
        lblTablesHeader.setText("Tables");
        lblTablesHeader.setToolTipText("");
        monitorPanel.add(lblTablesHeader, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 120, -1, -1));

        lblNumWaiting.setText("Num Waiting:");
        lblNumWaiting.setToolTipText("");
        monitorPanel.add(lblNumWaiting, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 150, -1, -1));

        lblAverageWaitTime.setText("Average Wait Time:");
        lblAverageWaitTime.setToolTipText("");
        monitorPanel.add(lblAverageWaitTime, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 170, -1, -1));

        lblOffersHeader.setFont(new java.awt.Font("Lucida Grande", 1, 14));
        lblOffersHeader.setText("Offers");
        lblOffersHeader.setToolTipText("");
        monitorPanel.add(lblOffersHeader, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 230, -1, -1));

        lblOffersSpend.setText("Spend:");
        lblOffersSpend.setToolTipText("");
        monitorPanel.add(lblOffersSpend, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 250, -1, -1));

        lblOffersDiscount.setText("Discount:");
        lblOffersDiscount.setToolTipText("");
        monitorPanel.add(lblOffersDiscount, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 270, -1, -1));

        lblOrdersHeader.setFont(new java.awt.Font("Lucida Grande", 1, 14));
        lblOrdersHeader.setText("Orders");
        lblOrdersHeader.setToolTipText("");
        monitorPanel.add(lblOrdersHeader, new org.netbeans.lib.awtextra.AbsoluteConstraints(700, 110, -1, -1));

        lblMostOrdered.setText("Most Ordered:");
        lblMostOrdered.setToolTipText("");
        monitorPanel.add(lblMostOrdered, new org.netbeans.lib.awtextra.AbsoluteConstraints(620, 130, -1, -1));

        lblMostOrderedValue.setToolTipText("");
        monitorPanel.add(lblMostOrderedValue, new org.netbeans.lib.awtextra.AbsoluteConstraints(770, 130, -1, -1));

        lblLeastOrdered.setText("Least Ordered:");
        lblLeastOrdered.setToolTipText("");
        monitorPanel.add(lblLeastOrdered, new org.netbeans.lib.awtextra.AbsoluteConstraints(620, 160, -1, -1));

        lblLeastOrderedValue.setToolTipText("");
        monitorPanel.add(lblLeastOrderedValue, new org.netbeans.lib.awtextra.AbsoluteConstraints(770, 160, -1, -1));

        lblTotalReceipts.setText("Total Receipts:");
        lblTotalReceipts.setToolTipText("");
        monitorPanel.add(lblTotalReceipts, new org.netbeans.lib.awtextra.AbsoluteConstraints(620, 200, -1, -1));

        lblTotalReceiptsValue.setToolTipText("");
        monitorPanel.add(lblTotalReceiptsValue, new org.netbeans.lib.awtextra.AbsoluteConstraints(770, 200, -1, -1));

        lblKitchenHeader.setFont(new java.awt.Font("Lucida Grande", 1, 14));
        lblKitchenHeader.setText("Kitchen");
        lblKitchenHeader.setToolTipText("");
        monitorPanel.add(lblKitchenHeader, new org.netbeans.lib.awtextra.AbsoluteConstraints(700, 230, -1, -1));

        lblAveragePrepTime.setText("Average Prep Time:");
        lblAveragePrepTime.setToolTipText("");
        monitorPanel.add(lblAveragePrepTime, new org.netbeans.lib.awtextra.AbsoluteConstraints(620, 270, -1, -1));

        lblAveragePrepTimeValue.setToolTipText("");
        monitorPanel.add(lblAveragePrepTimeValue, new org.netbeans.lib.awtextra.AbsoluteConstraints(770, 270, -1, -1));

        lblDisplay.setFont(new java.awt.Font("Lucida Grande", 1, 14));
        lblDisplay.setText("Display:");
        lblDisplay.setToolTipText("");
        monitorPanel.add(lblDisplay, new org.netbeans.lib.awtextra.AbsoluteConstraints(356, 80, -1, -1));

        comboDisplayMenu.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select One...", "Console", "Customer Queue", "Orders Queue", "Tables", "Menu" }));
        comboDisplayMenu.setToolTipText("");
        comboDisplayMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                comboDisplayMenuActionPerformed(evt);
            }
        });
        monitorPanel.add(comboDisplayMenu, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 75, 180, -1));

        jScrollPane1.setToolTipText("");

        txtareaDisplay.setColumns(20);
        txtareaDisplay.setRows(5);
        txtareaDisplay.setToolTipText("");
        jScrollPane1.setViewportView(txtareaDisplay);

        monitorPanel.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 110, 390, 310));

        lblNumWaitingValue.setToolTipText("");
        monitorPanel.add(lblNumWaitingValue, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 150, -1, -1));

        lblAverageWaitTimeValue.setToolTipText("");
        monitorPanel.add(lblAverageWaitTimeValue, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 170, -1, -1));

        txtOfferSpendValue.setToolTipText("");
        monitorPanel.add(txtOfferSpendValue, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 240, 100, -1));

        txtOfferDiscountValue.setToolTipText("");
        monitorPanel.add(txtOfferDiscountValue, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 270, 100, -1));

        getContentPane().add(monitorPanel, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnSetNumTablesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSetNumTablesActionPerformed
        if (sim != null) {
            sim.stop();
        } 
            String input = null;
            int numTables = Consts.MAX_TABLES;
            boolean validated = false;
            while (!validated) {
                input = JOptionPane.showInputDialog(null, "Enter number of tables in the restaurant: ",
                        Consts.MAX_TABLES);
                try {
                    numTables = Integer.parseInt(input);
                    Consts.MAX_TABLES = numTables;
                    validated = true;
                } catch (NumberFormatException nfe) {
                }
                if (input == null) {
                    break;
                }
            }
    }//GEN-LAST:event_btnSetNumTablesActionPerformed

    private void btnSetCustomerFlowRateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSetCustomerFlowRateActionPerformed
        if (sim != null) {
            sim.stop();
        } 
            String input = null;
            int flow = Consts.CUSTOMER_FLOW;
            boolean validated = false;
            while (!validated) {
                input = JOptionPane.showInputDialog(null,
                        "Enter a new rate (i.e. clock ticks\nbetween customer arrivals): ", Consts.CUSTOMER_FLOW);
                try {
                    flow = Integer.parseInt(input);
                    Consts.CUSTOMER_FLOW = flow;
                    validated = true;
                } catch (NumberFormatException nfe) {
                }
                if (input == null) {
                    break;
                }
            }    
    }//GEN-LAST:event_btnSetCustomerFlowRateActionPerformed

    private void btnSetClockRateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSetClockRateActionPerformed
        if (sim != null) {
            sim.stop();
        } 
            String input = null;
            int clockRate = Consts.CLOCK_RATE;
            boolean validated = false;
            while (!validated) {
                input = JOptionPane.showInputDialog(null, "Enter clock rate in milliseconds: ",
                        Consts.CLOCK_RATE);
                try {
                    clockRate = Integer.parseInt(input);
                    Consts.CLOCK_RATE = clockRate;
                    validated = true;
                } catch (NumberFormatException nfe) {
                }
                if (input == null) {
                    break;
                }
            }       
    }//GEN-LAST:event_btnSetClockRateActionPerformed

    private void btnStartSimulationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStartSimulationActionPerformed
        sim = new Simulation();
        sim.setObserver(this);

        t = new Thread(sim, "Restaurant Simulation");
        t.start();
        sim.begin();
        
        txtareaDisplay.setText("");
        comboDisplayMenu.setSelectedIndex(0);
        
    }//GEN-LAST:event_btnStartSimulationActionPerformed

    private void btnStopSimulationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStopSimulationActionPerformed
        if (sim != null) {
            sim.stop();
            sim.setExit(true);
        }
    }//GEN-LAST:event_btnStopSimulationActionPerformed

    private void comboDisplayMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboDisplayMenuActionPerformed
        int optionSelected = comboDisplayMenu.getSelectedIndex();
        switch (optionSelected) {
            case 0:
                txtareaDisplay.setText("");
                break;
            case 1:
                txtareaDisplay.setText("");
                break;
            case 2:
                txtareaDisplay.setText("");
                txtareaDisplay.append(sim.sys.getCustomersQueue());
                break;
            case 3:
                txtareaDisplay.setText("");
                txtareaDisplay.append(sim.sys.getOrdersQueue());
                break;
            case 4:
                txtareaDisplay.setText(sim.sys.getTablesforUI());
                break;
            case 5:
                txtareaDisplay.setText("");
                txtareaDisplay.append(sim.sys.getMenu());
                break;
        }
    }//GEN-LAST:event_comboDisplayMenuActionPerformed

    private void btnChangeStrategyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnChangeStrategyActionPerformed
                Object[] strategyTypes = {"Select One...", "First-Come, First-Served",
            "Similar Items Together", "Shortest Prep Time First"};
        Object selectedStrategy = JOptionPane.showInputDialog(null,
                "Select Kitchen Queue Prep Strategy: ", "Input",
                JOptionPane.INFORMATION_MESSAGE, null,
                strategyTypes, strategyTypes[0]);
        if (selectedStrategy != null) {
            if (!selectedStrategy.equals(strategyTypes[0])) {
                if (selectedStrategy.equals(strategyTypes[1])) {
                    Logger.GetInstance().LogMessage("FCFS selected");
                }
                if (selectedStrategy.equals(strategyTypes[2])) {
                    Logger.GetInstance().LogMessage("SimilarItemsTogether selected");
                }
                if (selectedStrategy.equals(strategyTypes[3])) {
                    Logger.GetInstance().LogMessage("Shortest Prep Time First selected");
                }
            }
        }
    }//GEN-LAST:event_btnChangeStrategyActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {

        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new SimulationUI().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnChangeStrategy;
    private javax.swing.JButton btnSetClockRate;
    private javax.swing.JButton btnSetCustomerFlowRate;
    private javax.swing.JButton btnSetNumTables;
    private javax.swing.JButton btnStartSimulation;
    private javax.swing.JButton btnStopSimulation;
    private javax.swing.JComboBox comboDisplayMenu;
    private javax.swing.JPanel controlPanel;
    private javax.swing.JPanel headerPanel;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparatorControl;
    private javax.swing.JSeparator jSeparatorMonitor;
    private javax.swing.JLabel lblAveragePrepTime;
    private javax.swing.JLabel lblAveragePrepTimeValue;
    private javax.swing.JLabel lblAverageWaitTime;
    private javax.swing.JLabel lblAverageWaitTimeValue;
    private javax.swing.JLabel lblControlPanel;
    private javax.swing.JLabel lblDisplay;
    private javax.swing.JLabel lblKitchenHeader;
    private javax.swing.JLabel lblLeastOrdered;
    private javax.swing.JLabel lblLeastOrderedValue;
    private javax.swing.JLabel lblLogo;
    private javax.swing.JLabel lblMonitorView;
    private javax.swing.JLabel lblMostOrdered;
    private javax.swing.JLabel lblMostOrderedValue;
    private javax.swing.JLabel lblNumWaiting;
    private javax.swing.JLabel lblNumWaitingValue;
    private javax.swing.JLabel lblOffersDiscount;
    private javax.swing.JLabel lblOffersHeader;
    private javax.swing.JLabel lblOffersSpend;
    private javax.swing.JLabel lblOrdersHeader;
    private javax.swing.JLabel lblRole;
    private javax.swing.JLabel lblTablesHeader;
    private javax.swing.JLabel lblTotalReceipts;
    private javax.swing.JLabel lblTotalReceiptsValue;
    private javax.swing.JPanel monitorPanel;
    private javax.swing.JTextField txtOfferDiscountValue;
    private javax.swing.JTextField txtOfferSpendValue;
    private javax.swing.JTextArea txtareaDisplay;
    // End of variables declaration//GEN-END:variables




    @Override
    public void update(Observable arg0, Object arg1) {
        //check arg0 to see if its CustomerQ, Tables or Orders
        String changedClass = arg0.getClass().getCanonicalName();

        if (changedClass == Consts.CUSTOMERQ) {
            CustomerQueue qCustomers = (CustomerQueue) arg0;
                LinkedList<Customer> llCustomers = qCustomers.getCustomerQueue();
            if (comboDisplayMenu.getSelectedItem() == "Customer Queue") {

                // clear text area
                txtareaDisplay.setText("");
                // Display Customers
                txtareaDisplay.append(qCustomers.toString());
                
            }
            lblNumWaitingValue.setText(qCustomers.getCustomerQueue().size()+"");
            lblAverageWaitTimeValue.setText(CustomerQueue.getAverageWaitingTime()+"");
        }


        if (changedClass == Consts.ORDERS) {
            if (comboDisplayMenu.getSelectedItem() == "Orders Queue") {
            	
                Orders aOrders = (Orders) arg0;
                // clear text area
                txtareaDisplay.setText("");
                // Display orders
                txtareaDisplay.append(aOrders.toString());
                

            }
            lblAveragePrepTimeValue.setText(Orders.getAvgPrepTime());
            lblMostOrderedValue.setText(Integer.toString(Orders.getMaxOrders()));
            lblLeastOrderedValue.setText(Integer.toString(Orders.getMinOrders()));
        }


        if (changedClass == Consts.TABLES) {
            if (comboDisplayMenu.getSelectedItem() == "Tables") {

                Tables aTables = (Tables) arg0;
                // clear text area
                txtareaDisplay.setText("");
                //Display Tables
                txtareaDisplay.append(aTables.toString());
            }
        }

        if (changedClass == Consts.LOGGER) {
            if (comboDisplayMenu.getSelectedItem() == "Console") {
                String strMessage = (String) arg1;
                // do not clear text area this is done in actionPerformed
                txtareaDisplay.append(strMessage + Consts.newline);
            }
        }
    }
}
